package main.test.SparkAPI.Baics.classApi

/**
 * Sealed Traits
 * Suppose you want to repr all suits in a deck of
 * playing cards --- the ones you usually use for a game of poker:
 * clubs,diamonds , harts ,spades. You need to express the
 * genenral concept of a symbol, but need to make sure that there
 * are precisely four of its impl.You can achieve it by using sealed trait.
 *
 */
sealed trait Suit

object Clubs extends Suit
object Diamonds extends Suit
object Hearts extends Suit
object Spades extends Suit

/**
 * use sealed trait to limit the elements that extend it.
 * wHEN using keywod sealed, you inform the compiler the components
 * extend the trait are in the same file where the interface is declared.
 * Thank to it, the compiler knows all the possible implementations for a give trait, and
 * can warn you if your code forgets to consider all of them (more on this when
 * you lean about pattern matching)
 * In other words, compiler can infer a suit is either clubs or Diamonds or hearts or spades
 * You can refer to this concept as union type or coproduct.
 *
 */